package gbench.appdemo.mall.data;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;

import gbench.common.tree.LittleTree.SQL;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 
 * @author gbench
 *
 */
public class ConfigApp {
    
    @Data @AllArgsConstructor @NoArgsConstructor 
    public static class Tenant{
        
        /**
         * 构造函数
         * @param name
         */
        public Tenant(final String name) {
            this.name = name;
        }
        
        private String id = UUID.randomUUID().toString();
        private String name;
    }
    
    @Data @AllArgsConstructor @NoArgsConstructor 
    public static class TenantApp{
        
        /**
         * 构造函数
         * @param name
         */
        public TenantApp(final String name,final List<String> configItems) {
            this.name = name;
            this.configItems = configItems;
        }
        
        /**
         * 构造函数
         * @param name
         */
        public TenantApp(final String name,String ... configItems) {
            this.name = name;
            this.configItems = Arrays.asList(configItems);
        }
        
        /**
         * 配置项目
         * @return
         */
        public List<String> getConfigItems(){
            return this.configItems;
        }
        
        private List<String> configItems = new LinkedList<String>();
        private String id = UUID.randomUUID().toString();
        private String name;
    }
    
    /**
     * 租户应用配置
     * @author gbench
     *
     */
    @Data @AllArgsConstructor @NoArgsConstructor 
    public static class TenantAppConfig{
        
        /**
         * 
         * @return
         */
        public String getConfig(String key) {
            return null;
        }
        
        public void initialize() {
            
            
            
        }
        
        /**
         * 获取SQL builder
         * @return SQL.Builder
         */
        public SQL.Builder getSqlBuilder(){
            return SQL.builder(configTableName);
        }
        
        private Tenant referrence;
        private Tenant tenant;
        private TenantApp tenantApp;
        
        private MallDataApp dataApp = new MallDataApp("db1");
        private String configTableName = "t_tenant_config";
    }

}
